package com.wyh.apitest.transformation.simple

import org.apache.flink.streaming.api.scala._

object TestDemo {
  def main(args: Array[String]): Unit = {
    val streamEnv = StreamExecutionEnvironment.getExecutionEnvironment
    streamEnv.setParallelism(1)


    //map
    val stream1: DataStream[Int] = streamEnv.fromElements(1,2,3,4,5)
    stream1.map(s=>{
      s+2
    }).print("map操作：")

    //flatmap
    val list2: List[String] = List("1 2","3 4")
    val stream2: DataStream[String] = streamEnv.fromCollection(list2)
    stream2.flatMap(s=>{
      s.split(" ")
    }).print("flatmap操作：")

    //Filter
    stream1.filter(x=>{
      x==1
    }).print("filter操作：")






    streamEnv.execute("简单转换操作演示")

  }
}